package org.jeecg.modules.xl.order.utils;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class StrCommonUtil {

    /**
     * 获取字符中的数字
     * @param str
     * @return
     */
    public static int getStringNumber(String str){
        if (str == null){
            return 0;
        }
        StringBuilder numbers = new StringBuilder();

        // 定义正则表达式，匹配数字
        Pattern pattern = Pattern.compile("\\d+");
        Matcher matcher = pattern.matcher(str);

        // 查找所有匹配的数字
        while (matcher.find()) {
            numbers.append(matcher.group()); // 添加到结果中
        }
        return Integer.parseInt(numbers.toString());
    }
}
